<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="time"></div>
    <!-- 表格效果 -->
    <table border="1" id="tables">
      <tr>
        <td>1-1</td>
        <td>1-2</td>
        <td>1-3</td>
        <td>1-4</td>
      </tr>
      <tr>
        <td>2-1</td>
        <td>2-2</td>
        <td>2-3</td>
        <td>2-4</td>
      </tr>
      <tr>
        <td>3-1</td>
        <td>3-2</td>
        <td>3-3</td>
        <td>3-4</td>
      </tr>
      <tr>
        <td>4-1</td>
        <td>4-2</td>
        <td>4-3</td>
        <td>4-4</td>
      </tr>
    </table>
    <script>
      var days = document.querySelector('#time');
      console.log(days);
      var app = document.body;
      var timeOne = new Date(2023, 4, 1, 00, 00, 00);
      var timeTwo = new Date();
      console.log(timeTwo);
      var dtime = Math.ceil((timeOne.getTime() - timeTwo.getTime()) / 1000);

      console.log(dtime);
      var d = Math.floor(dtime / 60 / 60 / 24); //天
      console.log(d);
      var h = Math.floor((dtime / 60 / 60) % 24); //时
      var m = Math.floor((dtime / 60) % 60); //分
      var s = Math.floor(dtime % 60); //秒
      // return d +'天'+h +'时' + m +'分' +s +'秒';
      var num = `距离2023五一还有${d}天${h}小时${m}分钟${s}秒`;
      console.log(num);

      //表格效果
      var tableEl = document.getElementById('tables');
      var rowEl = tableEl.rows[1];
      var j = 0;
      for (var i = 0; i < 4; i++) {
        if (j < 4) {
          rowEl = tableEl.rows[i];
          rowEl.cells[j].style.backgroundColor = 'red';
        }
        ++j;
      }
    </script>
  </body>
</html>
